package com.leilei.dao.impl;

import com.leilei.controller.Tadministrator;
import com.leilei.dao.ITadministratorDao;
import com.leilei.util.DBUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class TadministratorDaoImpl implements ITadministratorDao {

    private QueryRunner queryRunner = new QueryRunner(DBUtil.getDataSource());

    @Override
    public Tadministrator selectAdminByUP(String username, String password) {

        String sql = "select id, username, password from Tadministrator where username = ? and password = ?";

        try {
            return queryRunner.query(sql,new BeanHandler<Tadministrator>(Tadministrator.class), username, password);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

        return null;
    }
}
